package ext.csc.component.numbergen.bean;

import java.io.File;
import java.util.HashMap;

import ext.csc.component.numbergen.utilities.PropertiesUtil;

public class PropertiesBean {
	private String filepath = File.separator + "codebase" + File.separator + "ext" + File.separator + "csc" + 
								File.separator + "component" + File.separator + "numbergen" + File.separator + 
								"config" + File.separator + "NumberGen.properties";
	private HashMap hmProperties;
	
	private String numberFormat;
	private String sequenceFormat;
	private int sequenceBeginAt;
	private String adminGroup;
	
	public PropertiesBean(){
		hmProperties = PropertiesUtil.readProperties(filepath);
		numberFormat = (String)hmProperties.get("GenerationNumber.Format");
		sequenceFormat = (String)hmProperties.get("Sequence.Format");
		sequenceBeginAt = Integer.parseInt((String) hmProperties.get("Sequence.BeginAt"));
		adminGroup = (String)hmProperties.get("Administration.Group");
	}
	
	public String getValue(String key){
		String strValue = (String) hmProperties.get(key);
		if (strValue == null || "".equals(strValue))
			return "";
		strValue=strValue.trim();
		return strValue;
	}
	
	public String getNumberFormat() {
		return numberFormat;
	}

	public String getSequenceFormat() {
		return sequenceFormat;
	}

	public int getSequenceBeginAt() {
		return sequenceBeginAt;
	}
	
	public String getAdminGroup(){
		return adminGroup;
	}
}
